#pragma once

#include "MyApp.h"

// LOG out
#define PRINT_LOG(txt)	if (AUIDocViewMainFrame::GetCommandPanel())	AUIDocViewMainFrame::GetCommandPanel()->AddLine (txt);	
#define PRINT_ERROR(txt)	if (AUIDocViewMainFrame::GetCommandPanel())	AUIDocViewMainFrame::GetCommandPanel()->AddLine (txt);	


//************************
// statusbar
class CProgressBarManager
{
public:
	CProgressBarManager ():max_val(1.0),inc_statusbar(0.0),val_statusbar(0.0),b_AutoInc(false){};
	~CProgressBarManager (){AUIDocViewMainFrame::GetStatusBar ()->SetProgressValue(0,_T(""));};

	void SetValue (const long &val, const wchar_t* txt)
	{
		AUIDocViewMainFrame::GetStatusBar ()->SetProgressValue(val,txt);
	}
	
	void AutoIncrement (const wchar_t *txt = L"")
	{
		if (b_AutoInc)
		{
			val_statusbar += inc_statusbar;
			AUIDocViewMainFrame::GetStatusBar ()->SetProgressValue((long)val_statusbar,txt);
		}
	};
	void InintAutoIncrement (const double &max_val_)
	{
		if (max_val < 1e-10) return;
		
		max_val = max_val_;
		inc_statusbar = 100.0/max_val;
		b_AutoInc = true;
	};

private:
	double max_val;
	double inc_statusbar;
	double val_statusbar;
	bool b_AutoInc;
};
//************************
#define INIT_STATUSBAR CProgressBarManager PB_;
#define SETPROGRESS(val,txt) PB_.SetValue(val,txt);
#define HIDEPROGRESS PB_.SetValue(0,L"");
#define INIT_AUTO_INCREMENT_PROGRESSBAR(max_val) PB_.InintAutoIncrement(max_val);
#define AUTO_INCREMENT_PROGRESSBAR(txt) PB_.AutoIncrement(txt);
